//
//  CarModel.h
//  INMOTION
//
//  Created by Kyle on 14-4-24.
//  Copyright (c) 2014年 Inmotion. All rights reserved.
//

#import "IMTModel.h"
#import "IMTBatteryModel.h"
#import "IMTCANMessage.h"
#import "IMTCarStatistics.h"


#import "L9_CarModel.h"

/*
 * 车辆工作模式
 */
typedef NS_ENUM(NSInteger, CarMode) {
    CarModeFree = 0,               //空闲模式 L6柔和模式
    CarModeLoaded = 1,             //行车模式 L6激情模式,L, //自动回零模式，L8油门模式
    CarModeAutoSetZero = 2,        //自动回零模式，L8滑行模式
    CarModeGetInAngleTooLarge = 3, //上车角度过大，
    CarModeSelfCheck = 4,          //自检模式
    CarModeLocked = 5,             // 锁车报警模式//E1锁车
    CarModeFalutPark = 6,          //错误停车模式
    CarModeAssistant = 7,          //助力模式
    CarModeAutoWalk = 8,           //自动行走模式
    CarModePowerOff = 9,           //关机模式
    CarModePWMSTOP = 10,           //PWMSTOP模式
    CarModeFish = 11,              //新手模式
    CarModeShortHandle = 12,       //短把手模
};

typedef NS_ENUM(NSInteger,RemoteControlModeSelected){
    BeginnerMode = 0,  //新手模式
    NormalMode,        //普通模式
    SelfBalancedModel, //自平衡模式
};

/*
 * 控制类型定义
 */
typedef NS_ENUM(NSInteger, IMTCarControlType) {
    
    IMTCarControlTypeFishPowerOn = 1,          //新手开机
    IMTCarControlTypeNormalPowerOn = 2,        //普通开机
    IMTCarControlTypeLockCar = 3,              //锁车
    IMTCarControlTypeUnlockCar = 4,            //解锁
    IMTCarControlTypePowerOff = 5,             //关机
    IMTCarControlTypeSwitchToFishMode = 6,     //切换至新手模式 //E1开启自动巡航
    IMTCarControlTypeSwitchToNormalMode = 7,   // 切换至普通模式 //E1关闭自动巡航
    IMTCarControlTypeSwitchToAssistantMode = 8,//进入助力模式
    IMTCarControlTypeQuitAssistantMode = 9,    //退出助力模式
    IMTCarControlTypeSelfCheck = 10,           //开始自检
    IMTCarControlTypeTurnOnFrontLight = 11,    //开启前灯
    IMTCarControlTypeTurnOffFrontLight = 12,   //关闭前灯

    // L6
    IMTCarControlTypeSwitchToPassionMode = 13,  //切换至激情模式,L8油门
    IMTCarControlTypeSwitchToSoftMode = 14,     //切换至柔和模式，l8滑行模式

    // V8
    IMTCarControlTypeTurnOnLightEffect = 15,    // 开启灯效//C1C2自平衡模式
    IMTCarControlTypeTurnOffLightEffect = 16,   // 关闭灯效
    
    // V10
    IMTCarControlTypeSpeaker = 17,              // 鸣笛
    IMTCarControlTypeOpenTransportMode = 18,    // 开启运输模式
    IMTCarControlTypeCloseTransportMode = 19,   // 关闭运输模式
    IMTCarControlTypeOpenMusicPlayStandby = 20,
    IMTCarControlTypeCloseMusicPlayStandby = 21, // V10音乐模式待机 、P2儿童锁功能开关
    
    // P2新加功能 -1.2.10后版本
    IMTCarControlTypeOverSpeedAlarlmOn = 23,    // 开启超速报警
    IMTCarControlTypeOverSpeedAlarlmOff = 24   // 关闭超速报警

};

typedef NS_ENUM(NSInteger, WarningType) {
    WarningTypeLimitSpeed = 1,
    WarningTypeSound,
};

typedef NS_ENUM(NSInteger, DefaultLanguage) {
    DefaultLanguageEnglish, //英文
    DefaultLanguageChinese  //中文
};

// 车型类别
typedef NS_ENUM(NSUInteger, IMCarTypeCode) {
    IMCarTypeCodeOld = 0,      // 旧车型
    IMCarTypeCodeR0 = 1 ,      // E2E3车型
    IMCarTypeCodeL9 = 2 ,      // L9
    IMCarTypeCodeVX = 3 ,      // VX
};


//录制动作采样间隔
extern const CGFloat kIMTCarSamplingInterval;

//R1车辆宽度
extern const CGFloat kIMTCarTypeR1BodyWidth;

//==================================== 车辆功能支持版本 =============================================
// 车辆系列号 --- 车型的标识
/// R系列
#define IMTCarSeriesR1(carType) ([carType hasPrefix:@"0101"])
#define IMTCarSeriesR2(carType) ([carType hasPrefix:@"0102"])

/// L6系列
#define IMTCarSeriesL6(carType) ([carType hasPrefix:@"0301"] || [carType hasPrefix:@"0302"])
#define IMTCarSeriesLively(carType) ([carType hasPrefix:@"030201"] || [carType hasPrefix:@"030202"])

/// L8系列
#define IMTCarSeriesL8(carType) ([carType hasPrefix:@"0304"])
#define IMTCarSeriesL8F(carType) ([carType hasPrefix:@"030402"])
#define IMTCarSeriesL8F_1(carType) ([carType hasPrefix:@"030403"]) // L8F瑞士
#define IMTCarSeriesL8F_2(carType) ([carType hasPrefix:@"030404"]) // L8F挪威
#define IMTCarSeriesL8D(carType) ([carType hasPrefix:@"030405"]) // L8D华为定制
#define IMTCarSeriesL8S(carType) ([carType hasPrefix:@"030406"]) // L8S
#define IMTCarSeriesL8SP(carType) ([carType hasPrefix:@"030407"]) // L8S+
#define IMTCarSeriesL8DF(carType) ([carType hasPrefix:@"030408"]) // L8DF
#define IMTCarSeriesL8NW(carType) ([carType hasPrefix:@"030409"]) // L8系列罗马尼亚定制版

/// L系列
#define IMTCarSeriesL(carType) (IMTCarSeriesL8(carType) || IMTCarSeriesL6(carType))

/// V3系列
#define IMTCarSeriesV3(carType) ([carType hasPrefix:@"0201"])
#define IMTCarSeriesV3C(carType) ([carType hasPrefix:@"020102"])
#define IMTCarSeriesV3P(carType) ([carType hasPrefix:@"020103"])
#define IMTCarSeriesV3S(carType) ([carType hasPrefix:@"020104"])

/// V5系列
#define IMTCarSeriesV5(carType) ([carType hasPrefix:@"0203"])
#define IMTCarSeriesV5Plus(carType) ([carType hasPrefix:@"020302"])
#define IMTCarSeriesV5F(carType)    ([carType hasPrefix:@"020303"])
#define IMTCarSeriesV5D(carType)    ([carType hasPrefix:@"020304"] || [carType hasPrefix:@"020309"]) // 新增车型V5C：58，功能参数同V5D
#define IMTCarSeriesG2(carType)     ([carType hasPrefix:@"020305"])
#define IMTCarSeriesG2L(carType)    ([carType hasPrefix:@"020306"])
#define IMTCarSeriesV5SE(carType)   ([carType hasPrefix:@"020307"])
#define IMTCarSeriesV5E(carType)    ([carType hasPrefix:@"020308"])

/// V6系列
#define IMTCarSeriesV6(carType) ([carType hasPrefix:@"0202"])

/// V8系列
#define IMTCarSeriesV8(carType) ([carType hasPrefix:@"0204"] && ![carType hasPrefix:@"020403"] && ![carType hasPrefix:@"020404"])
#define IMTCarSeriesG3(carType) ([carType hasPrefix:@"020402"])
#define IMTCarSeriesV8F(carType) ([carType hasPrefix:@"020403"] || [carType hasPrefix:@"020404"])
#define IMTCarSeriesV8S(carType) ([carType hasPrefix:@"020404"]) // 新增车新v8s -- 功能同v8f，里程不同

/// V10系列
#define IMTCarSeriesV10(carType) ([carType hasPrefix:@"0205"] || [carType hasPrefix:@"020403"] || [carType hasPrefix:@"020404"])
#define IMTCarSeriesV10F(carType) ([carType hasPrefix:@"020502"] || [carType hasPrefix:@"020504"])
#define IMTCarSeriesV10T(carType) ([carType hasPrefix:@"020505"])   // v10T = V10
#define IMTCarSeriesV10FT(carType) ([carType hasPrefix:@"020506"])  // V10FT = V10F
#define IMTCarSeriesV8V10(carType) (IMTCarSeriesV8(carType) || IMTCarSeriesV10(carType))

/// V系列
#define IMTCarSeriesV(carType) (IMTCarSeriesV3(carType) || IMTCarSeriesV5(carType) || IMTCarSeriesV6(carType) || IMTCarSeriesV8(carType) || IMTCarSeriesV10(carType))

/// P1系列
#define IMTCarSeriesP1(carType) ([carType hasPrefix:@"0401"])
#define IMTCarSeriesP1F(carType) ([carType hasPrefix:@"040102"])
#define IMTCarSeriesP1SE(carType) ([carType hasPrefix:@"040103"])
#define IMTCarSeriesP1H(carType) ([carType hasPrefix:@"040104"])

/// P2系列5
#define IMTCarSeriesP2(carType) ([carType hasPrefix:@"0402"])
#define IMTCarSeriesP2F(carType) ([carType hasPrefix:@"040202"])
#define IMTCarSeriesP2H(carType) ([carType hasPrefix:@"040203"])
#define IMTCarSeriesP2C(carType) ([carType hasPrefix:@"040204"])
#define IMTCarSeriesP2U(carType) ([carType hasPrefix:@"040205"]) // 新增p2旗舰版
#define IMTCarSeriesS2(carType) ([carType hasPrefix:@"0403"])
#define IMTCarSeriesP(carType) (IMTCarSeriesP1(carType) || IMTCarSeriesP2(carType) || IMTCarSeriesS2(carType))

/// 扭扭车系列 -- D1\D2\B2\HC
#define IMTCarSeriesHC(carType) ([carType hasPrefix:@"0501"] || [carType hasPrefix:@"0502"])
#define IMTCarSeriesB2(carType) ([carType hasPrefix:@"0505"])
#define IMTCarSeriesD2(carType) ([carType hasPrefix:@"0504"])
#define IMTCarSeriesD2F(carType) ([carType hasPrefix:@"0504"])
#define IMTCarSeriesD1(carType) ([carType hasPrefix:@"0503"])

/// E系列
#define IMTCarSeriesR0(carType) ([carType hasPrefix:@"0103"] || [carType hasPrefix:@"0104"])  /// E系列车型（180=E2 -- 181=E3 - 182=E2P）
#define IMTCarSeriesE2(carType) ([carType hasPrefix:@"010301"])   /// E2系列车型
#define IMTCarSeriesE2P(carType) ([carType hasPrefix:@"010302"])  /// E2P系列车型
#define IMTCarSeriesE3(carType) ([carType hasPrefix:@"010401"])   /// E3系列车型
#define IMTCarSeriesE2Lite(carType) ([carType hasPrefix:@"010303"])   /// E2Lite系列车型
#define IMTCarSeriesE3Lite(carType) ([carType hasPrefix:@"010402"])   /// E3Lite系列车型

// E20
#define E20InmotionPrefix  @"E20"
// E20 -> LN
#define E20VegogoPrefix  @"LN"

/// E20
#define IMTCarSeriesE20(carType) ([carType hasPrefix:@"020a"])

/// 新协议车型
#define IMTCarSeriesLorin(carType) ([carType hasPrefix:@"0305"] || [carType hasPrefix:@"0306"] || [carType hasPrefix:@"0307"] || [carType hasPrefix:@"0308"] || [carType hasPrefix:@"020a"])

#define IMTCarSeriesL5(carType) ([carType hasPrefix:@"0306"])
#define IMTCarSeriesVX(carType) ([carType hasPrefix:@"0206"])

/// 设备号
#define IMTL9CaraMCDevice  0x31
#define IMTL9CaraBTDevice  0x32

#define IMTVXCaraHMZCDevice  0x21
#define IMTVXCaraMCDevice  0x22
#define IMTVXCaraBTDevice  0x23

#define IMTECaraMCDevice  0xA
#define IMTECaraBTDevice  0xB

#define IMTVCaraMCDevice  0x20
#define IMTVCaraBTDevice  0x21

#define IMTPCaraMCDevice  0x30

#define IMTLCaraMCDevice  0x30
#define IMTLCaraBTDevice  0x31

//蓝牙密码支持最低版本
extern NSString * const kIMTCarTypeR1SupportPasswordVersion;
extern NSString * const kIMTCarTypeR1NSupportOpenRemoteControlVersion;

//激活支持版本
extern NSString * const kIMTCarTypeV3SupportActivationVersion;
extern NSString * const kIMTCarTypeR1R2SupportActivationVersion;

//日志上传支持版本
extern NSString * const kIMTCarTypeV3SupportLogUploadVersion;

//L6单次骑行统计数据支持版本
extern NSString * const kIMTCarTypeL6SupportSingleRideStatisticsVersion;

@class UserModel, CANMessage, DetectionModel;

@interface CarModel : IMTModel

// 新车型
@property (nonatomic , strong) L9_CarModel *l9_CarModel;

@property (nonatomic, assign) NSInteger model;
@property (nonatomic, strong) NSString *password;
@property (nonatomic, strong) NSString *sn;
@property (nonatomic, assign) double batteryPercentage;
- (instancetype)initWithData:(NSData *)data;

//自定义
@property (nonatomic) IMTP2S32Params p2Params;          //!< p2参数
@property (nonatomic, assign) IMTP2S32Params s2Params;  //!< s2 参数
@property (nonatomic, strong) NSString *carId;
@property (nonatomic, strong) NSString *bleAddress;     // MAC
@property (nonatomic, strong) NSString *carName;        // 名称
@property (nonatomic, strong) NSString *carType;        // 型号
@property (nonatomic, strong) NSString *originCarType;  // 车辆原始型号
@property (nonatomic, strong) NSString *carTypeName;    // 型号名称
@property (nonatomic, strong) NSString *bleName;        // 蓝牙名称
@property (nonatomic, strong) UserModel *carOwner;     // 车主
@property (nonatomic, strong) NSString *mileageRanking;
@property (nonatomic, strong) NSString *mileageRankingPercentage;
@property (nonatomic) WarningType warningType;
@property (nonatomic) MapType mapType;
@property (nonatomic, strong) NSString *blePassword;     // 蓝牙密码
@property (nonatomic) BOOL shouldUploadStatistics;
@property (nonatomic) BOOL shouldCheckFirmware;
@property (nonatomic) BOOL isCarOwner;                   // 是否有用户绑定过
@property (nonatomic, assign) int carOwnerType;          // 车辆用户类型
@property (nonatomic) IMCarTypeCode carModelType;        // 当前车型
@property (nonatomic, strong) NSString *batteryVolume;
@property (nonatomic) NSInteger boardFeel;               // V3踏板灵敏度分级（2，3，4）
// V10踏板灵敏度(电机软硬度)参数的有效范围 2048 - 4096，默认4096, 和上面的boardFeel的区别有点重复，但是数值是连续的
@property (nonatomic) NSInteger pedalSensitivity;
@property (nonatomic , strong) NSString *salesTerritory;
@property (nonatomic, strong) NSString *isLock;
@property (nonatomic, strong) NSString *lockRange;
@property (nonatomic, strong) NSDictionary *lockRangeDic;
@property (nonatomic, strong) NSString *isRangeLock;
@property (nonatomic, strong) NSString *volume;      //音量
@property (nonatomic, strong) NSString *slidingTime; //滑行时间
@property (nonatomic, assign) double battery;        //电池百分比
@property (nonatomic, assign) double leftMiles;       // 剩余公里数 -- 剩余里程
@property (nonatomic, assign) double standPower;      // 额定功率
@property (nonatomic, assign) double maxPower;        // 最大功率
@property (nonatomic, assign) double maxRecoveryPower;// 最大回收功率
@property (nonatomic) CGFloat s1;                    //左轮行驶距离
@property (nonatomic) CGFloat s2;                    //右轮行驶距离

@property (nonatomic) BOOL supportPassword;          // 检查固件版本是否支持蓝牙密码
@property (nonatomic) BOOL supportActivation;
@property (nonatomic) BOOL supportFirmwareUpdate;    //支持更新

@property (nonatomic) double previousMileage;
@property (nonatomic, strong) NSDate *startDate;
@property (nonatomic, strong) NSString *durationString;

#pragma mark - 车辆统计数据开始
@property (nonatomic, assign) double current; //电流
@property (nonatomic, strong) NSMutableArray<NSNumber *> *currents;
@property (nonatomic, assign) double maxCurrent; // 最高电流

@property (nonatomic, assign) double phaseCurrent; // 相电流(A) = 相电流数值 * 0.011111(1/90)
@property (nonatomic, strong) NSMutableArray<NSNumber *> *phaseCurrents;
@property (nonatomic, assign) double maxPhaseCurrent;

@property (nonatomic, assign) double voltage; // 电压
@property (nonatomic, assign) double maxVoltage;
@property (nonatomic, strong) NSMutableArray<NSNumber *> *voltages;

@property (nonatomic, assign) double power; // 输入功率 = 电流 * 电压
@property (nonatomic, assign) double maxInputPower;
@property (nonatomic, assign) double averagePower;
@property (nonatomic, assign) double totalPower;
@property (nonatomic, strong) NSMutableArray<NSNumber *> *powers;

@property (nonatomic, strong) NSMutableArray<NSNumber *> *speeds;
@property (nonatomic, assign) double averageSpeed;  // 平均速度
@property (nonatomic, assign) double maxRideSpeed;  // 历史最高骑行速度
@property (nonatomic, assign) double speed;         // 速度; 转速（rad/s）= 速度数值 * 0.004925
@property (nonatomic, assign) double torque;        // 扭矩(N*m) = 相电流(A) * 0.8174
@property (nonatomic, assign) double maxTorque;
@property (nonatomic, strong) NSMutableArray<NSNumber *> *torques;

@property (nonatomic, assign) double outputPower;     // 输出功率(W) = 扭矩(N*m) * 转速（rad/s） = 扭矩 * 速度数值 * 0.004925
@property (nonatomic, assign) double maxOutputPower;
@property (nonatomic, strong) NSMutableArray<NSNumber *> *outputPowers;

@property (nonatomic, assign) double efficiency;      // 效率 = 输出功率 / 输入功率
@property (nonatomic, assign) double maxEfficiency;
@property (nonatomic, strong) NSMutableArray<NSNumber *> *efficiencies;

@property (nonatomic, assign) double acceleratedSpeed;// 加速度
@property (nonatomic, assign) double maxAcceleratedSpeed;
@property (nonatomic, strong) NSMutableArray<NSNumber *> *acceleratedSpeeds;

@property (nonatomic, assign) double temperature;     // 车体温度
@property (nonatomic, strong) NSMutableArray<NSNumber *> *temperatures;
@property (nonatomic, assign) double maxTemperature;

@property (nonatomic, assign) double motorTemperature;// 电机温度
@property (nonatomic, strong) NSMutableArray<NSNumber *> *motorTemperatures;
@property (nonatomic, assign) double maxMotorTemperature;

@property (nonatomic, assign) double finTemperature;  // 散热器温度
@property (nonatomic, strong) NSMutableArray<NSNumber *> *finTemperatures;
@property (nonatomic, assign) double maxFinTemperature;

@property (nonatomic, assign) double energy;            // 能耗 = 功率 / 速度
@property (nonatomic, assign) double maxEnergy;         // 最高能耗
@property (nonatomic, assign) double tripMileage;       // 本次行驶距离
@property (nonatomic, assign) double tripEnergy;        // 本次总耗能
@property (nonatomic, assign) double tripAverageEnergy; // 单次平均能耗
@property (nonatomic, assign) double sumOfTripEnergy;   // 保存每次的能耗之和为了求平均的能耗（除V10外，其他车型直接用单次耗能/单次里程）
@property (nonatomic, strong) NSMutableArray *tripEnergies;
@property (nonatomic, assign) double totalEnergy;       // 总耗能
@property (nonatomic, assign) double averageEnergy;     // 总平均能耗

// 用来计算除V10以外的车型的总能耗和总平均能耗
@property (nonatomic, strong) IMTCarStatistics *statistics;
@property (nonatomic, assign) double speedControl;      // 动态限速

#pragma mark 车辆统计数据结束 -
@property (nonatomic) RemoteControlModeSelected mode3;//模式选择
@property (nonatomic, assign) double mileage;         //总里程
@property (nonatomic) CarMode mode1;                  //当前工作模式
@property (nonatomic) CarMode mode2;                  //当前工作模式
@property (nonatomic, assign) BOOL fanSpinning;
@property (nonatomic, assign) BOOL isTransport;       // 是否运输模式
@property (nonatomic, assign) BOOL isLocked;          // V10的锁车模式

#pragma mark - 慢速数据
@property (nonatomic, strong) NSString *softwareVersion;    //整车软件版本号
@property (nonatomic, strong) NSString *pcSoftwareVersion;  //PC软件版本号
@property (nonatomic, strong) NSString *mcSoftwareVersion;  //MC软件版本号
@property (nonatomic, strong) NSString *hardwareVersion;    //硬件版本号
@property (nonatomic, strong) NSString *firmwareVersion;    //固件版本
@property (nonatomic, strong) NSString *carBootloaderVersion; // 引导程序版本号
@property (nonatomic, strong) NSMutableArray *versionData;  //版本号字典
@property (nonatomic, strong) NSMutableArray *hwVersionData;  //硬件版本号字典
@property (nonatomic, strong) NSMutableArray *deviceData;   //设备唯一ID字典
@property (nonatomic, assign) CGFloat currentMaxSpeed;      //当前最大速度
@property (nonatomic, assign) CGFloat maxSpeed;             //车型最大速度
@property (nonatomic, assign) CGFloat safeSpeed;            //安全速度
@property (nonatomic, assign) CGFloat rideTime;             //骑行时长
@property (nonatomic, strong) NSString *handleSensitivity;  //把手灵敏度
@property (nonatomic, strong) NSString *gpsSendGap;         //gps发送间隔
@property (nonatomic, strong) NSString *zeroPoint;          //前后零点
@property (nonatomic, assign) BOOL cruiseControl;           //自动巡航
@property (nonatomic, strong) NSString *language;           //默认语言
@property (nonatomic, assign) NSInteger standByTime;        //待机时长（要用到）
@property (nonatomic, assign) BOOL driverModeSwitch;        //驱动模式切换


@property (nonatomic, assign) CGFloat powerOnTime;             //开机时长

@property (nonatomic) BOOL gpsIsOff;           //gps开关状态
@property (nonatomic) BOOL warningToneIsOn;    //提示音开关
@property (nonatomic) BOOL speakerIsOn;        //喇叭开关
@property (nonatomic) BOOL lightIsOn;          //灯光开关 (L8照明灯开关)
@property (nonatomic , assign) NSUInteger r0LightState; // r0灯光状态
@property (nonatomic , assign) uint8_t r0BackOutSpeedState; // r0后退超速报警状态 bit1使能刹车灯，bit2允许锁车时关机，bit3锁车后不产生警报，bit4后退超速有警告
@property (nonatomic) BOOL atmosphereLampIsOn; //氛围灯开关
@property (nonatomic) BOOL handleIsOn;         //把手快捷功能
@property (nonatomic) BOOL autoLight;          //自动灯光

@property (nonatomic, assign) BOOL lightEffectIsOn;      //灯效开关
@property (nonatomic, assign) BOOL musicPlayStandbyIsOn; // 音乐播放待机
// p2新功能
@property (nonatomic, assign) BOOL isChildLock;          // 儿童锁 0:关闭， 1:打开
@property (nonatomic, assign) BOOL isOverSpeedAlarlm;    // 是否开启超速报警功能  0:关闭， 1:打开 新加

//L6
@property (nonatomic, assign) BOOL slideBootIsOn;
@property (nonatomic, assign) NSInteger speedUpSensitivity;
@property (nonatomic, strong) NSMutableArray *batterySections;
@property (nonatomic, strong) DetectionModel *detectionModel;
@property (nonatomic, assign) BOOL isPassionMode;

//R0
@property (nonatomic, assign) NSInteger assistModeValue;
@property (nonatomic, assign) NSInteger r0MaxSpeedModel; // r0最大限速模式

#pragma mark - Load
// 获取p2数据  by lgh
- (void)fetchP2Data;

// 获取S2数据  by lgh
- (void)fetchS2Data;

- (void)loadDailyRankingListWithData:(NSDictionary *)data;

//加载慢速数据
- (void)loadSlowInfoFromCANMessageData:(NSData *)data;

//加载快速数据
- (void)loadFastInfoFromCANMessageData:(NSData *)data;
// 获取快速数据里的速度和工作模式
- (void)loadFastWorkModelAndSpeedInfoFromCANMessageData:(NSData *)data;
- (void)loadSimpleFastInfoFromCANMessageData:(NSData *)data;

//加载音量
- (void)loadVolumeFromCANMessage:(NSData *)data;

//加载滑行时间
- (void)loadSlidingTimeFromCANMessage:(NSData *)data;

//加载语言
- (void)loadDefaultLanguageFromCANMessage:(NSData *)data;

- (void)loadL8MCInfoFromData:(NSData *)data;

- (void)loadR0DataFromData:(NSData *)data withSId:(u_int8_t)ID;
- (void)loadR0ComplexDataFromData:(NSData *)data withSId:(u_int8_t)ID;

#pragma mark - Get
#pragma mark - Save
//缓存默认车辆
- (void)saveCurrentCar;

//读取默认车辆（缓存）
- (void)loadCurrentCar;

//移除当前h车辆
+ (void)removeCurrentCar;

/**
*  把data转换成String
*
*  @param data 4个字节，第一个字节是大版本，第二个字节是小版本，最后两个字节是日期
*
*  @return 3.4.909 类似的字符串
*/
- (NSString *)versionStringFromData:(NSData *)data;


// 获取固件升级状态
- (void)getCarUpdateStateWithSuccessBlock:(void (^)(NSError *error, NSDictionary *result))success failBlock:(IMNewCarModelSettingFailBlock)fail;

@property (nonatomic, strong) IMTBatteryModel *batteryModel;

- (void)clearData;

- (void)loadCarTypeInfo;

- (void)loadCarInfoWithDictionary:(NSDictionary *)carInfo;

@end
